window.onload = function () {
    var form = layui.form;
    form.on('checkbox(select-all)', function(data){
        if(data.elem.checked==true){
            $("input[name='idList[]']").prop('checked',true)
        }else {
            $("input[name='idList[]']").prop('checked',false)
        }
        form.render('checkbox');
    });
    $(".reply").click(function () {
        var param = JSON.parse($(this).attr("data-list"));
        var uid = $(this).attr("data-uid");
        var url = $(this).attr("data-url");
        layer.prompt({
            formType: 2,
            value: '',
            title: '请输内容',
            area: ['800px', '350px']
        }, function(value, index, elem){

            $.ajax({
                type:'post',
                url:url,
                data:{
                    topic_id:param.topic_id,
                    topic_type:param.topic_type,
                    content:value,
                    from_uid:uid,
                    to_uid:param.from_uid,
                    is_status:1
                },
                success:function (res) {
                    if(res.code==1){
                        location.href = res.url;
                    }else{
                        layer.msg(res.msg)
                    }
                },
                error:function (error) {
                    layer.msg("网络错误请稍后再试")
                }
            })

        });
    })
}